﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class MenuChild : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            load_MenuChild();
        }
    }

    public void load_MenuChild()
    {
        MenuChildRepeater.DataSource = BusLogic.MenuChild.get_ALL_MENUCHILD();
        MenuChildRepeater.DataBind();
    }

    protected void cbxCheckALLMenuChild_CheckedChanged(object sender, EventArgs e)
    {
        if (cbxCheckALLMenuChild.Checked == true)
        {
            foreach (RepeaterItem item in MenuChildRepeater.Items)
            {
                CheckBox cbxCheckMenuChild = item.FindControl("cbxCheckMenuChild") as CheckBox;
                cbxCheckMenuChild.Checked = true;
            }
        }
        else
        {
            foreach (RepeaterItem item in MenuChildRepeater.Items)
            {
                CheckBox cbxCheckMenuChild = item.FindControl("cbxCheckMenuChild") as CheckBox;
                cbxCheckMenuChild.Checked = false;
            }
        }
    }

    protected void lbtDelete_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem item in MenuChildRepeater.Items)
        {
            CheckBox cb = (CheckBox)item.FindControl("cbxCheckMenuChild");

            if (cb.Checked == true)
            {
                TextBox txtMenuChildId = (TextBox)item.FindControl("txtMenuChildId");
                BusLogic.MenuChild.remove_MENUCHILD(int.Parse(txtMenuChildId.Text));
            }
        }

        load_MenuChild();
        cbxCheckALLMenuChild.Checked = false;
    }
}
